package strategy;


import java.util.ArrayList;
import projekt.Mediator;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Kam
 */
public class OneToOne extends strategy.Strategy {
    
    private float mAnswer;
    
    public OneToOne(String tempSpecial, ArrayList<String> tempOtherStrings) {
        super(tempSpecial, tempOtherStrings);
        mAnswer = 0;
        mNazwaAlgorytmu = "Dla aminokwasów";      
    }
   
    @Override
    protected void update() {
        Mediator.getRef().update(mNazwaAlgorytmu,this.mIndex);
    }

    @Override
    protected void end() {
        Mediator.getRef().update(mNazwaAlgorytmu,this.mIndex, String.valueOf(this.mAnswer));
    }

    @Override
    public void run() {
        update();
        int tempIdenticalChars = 0;
        for (int i = 0; i < this.mSpecial.length(); i++) {
            for (String stringFromArray : this.mOtherStrings) {
                if (this.mSpecial.charAt(i) == stringFromArray.charAt(i)) {
                    tempIdenticalChars++;
                    break;
                }
            }
        }
        this.mAnswer = ((float) tempIdenticalChars) / ((float) this.mSpecial.length());
        //System.out.println("Watek porównywania "+mIndex+" konczy prace prace");
        end();
    }
}
